#include <iostream>
using namespace std;

// select #1
void try1()
{	int *p;

	cout << "\n\nResults from selection #1" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;
}
// select #2
void try2()
{	int *p = NULL;

	cout << "\n\nResults from selection #2" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;
}
// select #3
void try3()
{	int *p = 0;

	cout << "\n\nResults from selection #3" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;
}
// select #4
void try4()
{	
	int num = 15;
	int *p = &num;

	cout << "\n\nResults from selection #4" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;

	delete p;

	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;
}
// select #5
void try5()
{	
	int *p = new int(21);

	cout << "\n\nResults from selection #5" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;

	delete p;

	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;
}

// select #6
void try6()
{	
	int *p = new int(21);

	cout << "\n\nResults from selection #6" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;

	delete p;
	delete p;

	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;
}

// select #7
void try7()
{
        int *p = new int(21);
        int *k = NULL;

        cout << "\n\nResults from selection #7" << endl;
        cout << "address in p is: " << p << endl;
        cout << "The value stored there is:" << *p << endl;

        delete p;
        k = new int; 

        cout << "address in k is: " << k << endl;
        cout << "The value stored there is:" << *k << endl;


}


// select #8
void try8()
{
	int *p = new int(15);
	int *k = p;

	cout << "\n\nResults from selection #8" << endl;
	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;

	delete p;
	int *g = new int(23);
	p = new int(90);

	cout << "address in p is: " << p << endl;
	cout << "The value stored there is:" << *p << endl;

	cout << "address in k is: " << k << endl;
	cout << "The value stored there is:" << *k << endl;

	cout << "address in g is: " << g << endl;
	cout << "The value stored there is:" << *g << endl;
}
int main()
{
	int sel;
	cout << "Enter selection:";
	cin >> sel;
    switch (sel)
    {	case 1:   try1(); break;
	    case 2:   try2(); break;
	    case 3:   try3(); break;
	    case 4:   try4(); break;
	    case 5:   try5(); break;
	    case 6:   try6(); break;
	    case 7:   try7(); break;
	    case 8:   try8();
    }
	return 0;
}
